<template>
  <div class="container">
    <page-header @click="$router.push('/home')" setClick></page-header>
    <div class="rent_result1">
      <img
        style="width: 141px; height: 141px;"
        :src="
          activeValue == 1
            ? require('@/assets/img/rent/ic_success.svg')
            : require('@/assets/img/rent/ic_failed@2x.png')
        "
      />
      <div
        class="rent_result_content"
        :class="{ rent_result_active: activeValue == 1 }"
      >
        {{ activeValue == 1 ? $t("home_success") : $t("home_failed") }}
      </div>
      <div class="rent_text">
        {{
          activeValue == 1 ? $t("home_takePBText") : $t("home_scanAgainText")
        }}
      </div>
    </div>
    <bottom-button
      @click="downApp"
      :title="activeValue == 1 ? $t('Download_app') : $t('home_scan2rent')"
    >
    </bottom-button>
  </div>
</template>
<script>
import share from "@/mixins/share";
export default {
  mixins: [share],
  data() {
    return {
      activeValue: 1,
      type: 1,
      androidDownloadUrl: "",
      iosDownloadUrl: ""
    };
  },
  created() {
    this.getLang();
    this.activeValue = this.$route.query.type;
    if (!this.$route.query.type) {
      this.$router.push("/home");
      return;
    }
  },
  mounted() {
    let configs = JSON.parse(localStorage.getItem("configs"));
    configs.forEach(item => {
      if (item.key == "android-download-url") {
        this.androidDownloadUrl = JSON.parse(item.value).user;
      }
      if (item.key == "ios-download-url") {
        this.iosDownloadUrl = JSON.parse(item.value).user;
      }
    });
  },
  methods: {
    downApp() {
      if (this.activeValue == 1) {
        this.downloadApp();
      } else {
        this.$router.push("/scan");
      }
    },
    // 下载app
    downloadApp() {
      let appType = this.global.terminal.platform;
      if (appType.android) {
        window.open(this.androidDownloadUrl);
      } else if (appType.ios) {
        window.open(this.iosDownloadUrl);
      }
    }
  }
};
</script>

<style lang="scss">
.container {
  background: #f5f5f7;
}
.rent_result1 {
  padding: 32px 14px 100px;
  text-align: center;
  .rent_result_content {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    color: #889dbb;
    line-height: 24px;
    margin-bottom: 8px;
  }
  .rent_result_active {
    color: var(--text-color) !important;
  }
  .rent_text {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: #889dbb;
    line-height: 16px;
  }
}
</style>
